package com.asyf.provider.common.tcc;

import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

/**
 * @Author yjz
 * @Date 2022/2/9 9:29
 */
@LocalTCC
public interface FirstAction {

    /*
   第一阶段的方法
   通过注解指定第二阶段的两个方法名

   BusinessActionContext 上下文对象，用来在两个阶段之间传递数据
   @BusinessActionContextParameter 注解的参数数据会被存入 BusinessActionContext
    */
    @TwoPhaseBusinessAction(name = "firstAction", commitMethod = "commit", rollbackMethod = "rollback")
    boolean prepare(BusinessActionContext businessActionContext, @BusinessActionContextParameter(paramName = "id") int id);

    // 第二阶段 - 提交
    boolean commit(BusinessActionContext businessActionContext);

    // 第二阶段 - 回滚
    boolean rollback(BusinessActionContext businessActionContext);
}
